{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/admin/webupload/style.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/static/admin/webupload/style.css">
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">

			<div class="ibox-content">
		    	 <form class="form-horizontal m-t" name="edit_rule" id="edit_rule" method="post" action="{:url('edit_rule')}">
					<input type="hidden" name="id" value="{$user_list.id}">
					<div class="form-group">
						<label class="col-sm-3 control-label">登录名：</label>
						<div class="input-group col-sm-4">
							<input type="admin_name" id="admin_name" name="admin_name" value="{$user_list.admin_name}" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					   <div class="form-group">
                            <label class="col-sm-3 control-label">用户头像：</label>
                            <div class="input-group col-sm-4">
                                <input type="hidden" id="data_photo" name="thumb" value="{$user_list.thumb}">
                                <div id="fileList" class="uploader-list" style="float:right"></div>
                                <div id="imgPicker" style="float:left">选择图片</div>
                                <img id="img_data" height="100px" style="float:left;margin-left: 50px;margin-top: -10px;" src="{$user_list.thumb}"/>
                            </div>
                        </div> 
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">管理员角色</label>
						<div class="input-group col-sm-4">
							<select name="pid" class="form-control">
								<option value="0">--默认--</option>
								{foreach name="list" item="vo"}
								<option value="{$vo.id}" {if condition="$group_id==$vo.id"} selected="selected"{/if}>{$vo.title}</option>
								{/foreach}
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">真实姓名：</label>
						<div class="input-group col-sm-4">
							<input type="real_name" id="real_name" name="real_name" value="{$user_list.real_name}" placeholder="真实姓名" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-3 control-label">登录密码：</label>
						<div class="input-group col-sm-4">
							<input type="password" id="admin_pwd" name="admin_pwd" value="{$user_list.admin_pwd}" placeholder="登录密码" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					                        <div class="form-group">
                            <label class="col-sm-3 control-label">状&nbsp;态：</label>
                            <div class="input-group col-sm-4 control">
                                <div class="mui-input-row mui-radio mui-left">
                                    <input type="radio" name='status' value="1" {if condition="$user_list['status'] eq 1 "}checked{/if}/>开启&nbsp;&nbsp;
                                    <input type="radio" name='status' value="0" {if condition="$user_list['status'] eq 0 "}checked{/if}/>关闭
                                </div>
                            </div>
                        </div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-3">
							<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
							<a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
						</div>
					</div>
					<div class="form-group">
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="__PUBLIC__/static/admin/webupload/webuploader.min.js"></script>
<script src="__PUBLIC__/static/admin/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__PUBLIC__/static/admin/ueditor/ueditor.all.js" type="text/javascript"></script>
<script type="text/javascript">
    var ueditor = UE.getEditor('content');
    var $list = $('#fileList');
    //上传图片,初始化WebUploader
    var uploader = WebUploader.create({
     
        auto: true,// 选完文件后，是否自动上传。   
        swf: '__PUB__/static/admin/webupload/Uploader.swf',// swf文件路径 
        server: "{:url('Upload/uploadface')}",// 文件接收服务端。
        duplicate :true,// 重复上传图片，true为可重复false为不可重复
        pick: '#imgPicker',// 选择文件的按钮。可选。

        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },

        'onUploadSuccess': function(file, data, response) {
            $("#data_photo").val(data._raw);
            $("#img_data").attr('src', '/public/uploads/face/' + data._raw).show();
        }
    });

    uploader.on( 'fileQueued', function( file ) {
        $list.html( '<div id="' + file.id + '" class="item">' +
            '<h4 class="info">' + file.name + '</h4>' +
            '<p class="state">正在上传...</p>' +
        '</div>' );
    });

    // 文件上传成功
    uploader.on( 'uploadSuccess', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传成功！');
    });

    // 文件上传失败，显示上传出错。
    uploader.on( 'uploadError', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传出错!');
    }); 


</script>

<script type="text/javascript">

    $(function(){
        $('#edit_rule').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });
        
        function checkForm(){
           
        }


        function complete(data){
            if(data.code==200){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('user/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1});
                return false;   
            }
        }
     
    });

</script>